function formatDate(date, fmt) {
    if (!fmt) {
        fmt = 'yyyy-MM-dd'
    }
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
    }
    let o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'h+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds()
    };
    for (let k in o) {
        if (new RegExp(`(${k})`).test(fmt)) {
            let str = o[k] + ''
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str))
        }
    }
    return fmt
}
function padLeftZero(str) {
    return ('00' + str).substr(str.length)
}
const FileManagerPlugin = require('filemanager-webpack-plugin');
module.exports = {
    publicPath :'./',
    productionSourceMap : true,
    configureWebpack: {
    plugins: [
        new FileManagerPlugin({
            events: {
                onEnd: {
                    // copy: [
                    //     { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },
                    //     { source: '/path/**/*.js', destination: '/path' },
                    // ],
                    // move: [
                    //     { source: '/path/from', destination: '/path/to' },
                    //     { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },
                    // ],
                    // mkdir: ['/path/to/directory/', '/another/directory/'],
                    archive: [
                        { source: 'dist', destination:`dist/tyslweb-new-${formatDate(new Date(),'MM-dd-hh-mm')}.zip` },
                        // { source: '/dist/**/*.js', destination: '/dist/tyslweb-new.zip' },
                        // { source: '/dist/font', destination: '/dist/tyslweb-new.zip' },
                        // { source: '/dist/favicon.ico', destination: '/dist/tyslweb-new.zip' },
                        // { source: '/dist/index.html', destination: '/dist/tyslweb-new.zip' },
                        // { source: '/dist/js', destination: '/dist/tyslweb-new.zip', format: 'zip' },
                        // {
                        //     source: '/path/fromfile.txt',
                        //     destination: '/path/to.tar.gz',
                        //     format: 'tar',
                        //     options: {
                        //         gzip: true,
                        //         gzipOptions: {
                        //             level: 1,
                        //         },
                        //         globOptions: {
                        //             // https://github.com/Yqnn/node-readdir-glob#options
                        //             dot: true,
                        //         },
                        //     },
                        // },
                    ],
                },
            },
        }),
    ]}
}
